package module

import (
	"time"

	redigo "github.com/gomodule/redigo/redis"
)
var pool        *redigo.Pool
type RedisConn struct {
	Redis    redigo.Conn
	Err      error
	redisVal interface{}
}
func RedisConnect()  {
	//连接服务器
	redisCfg := DefaultConf.Redis
	pool = &redigo.Pool{
		MaxIdle:     redisCfg.MaxIdle, //空闲数
		IdleTimeout: time.Duration(redisCfg.IdleTimeout) * time.Second,
		MaxActive:   redisCfg.MaxActive, //最大数
		Dial: func() (redigo.Conn, error) {
			c, err := redigo.Dial("tcp", redisCfg.Addr)
			if err != nil {
				return nil, err
			}
			if redisCfg.Password != "" {
				if _, err := c.Do("AUTH", redisCfg.Password); err != nil {
					c.Close()
					return nil, err
				}
			}
			return c, err
		},
	}

}
